<?php //jQuery Validation ?>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/lib/jwplayer/jwplayer.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
	     //Get the screen height and width
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();
     
        //Set height and width to mask to fill up the whole screen
        $('#loading').css({'width':maskWidth,'height':maskHeight,'position':'absolute','top':'0','left':'0','z-index':'1000'});

        $("#signup").click(function(e){
                    	
					$("#signup-form").validate();
					e.preventDefault;
					if($("#signup-form").valid()){ //register if form is valid
					    $("#signup").hide();
					    addmember($("#strFirstName").val(),$("#strLastName").val(),$("#strInstrument").val(),$("#month").val(),$("#day").val(),$("#year").val()); 
					
					}
		});
		

        
	});

	function del_member(x){
		var r=confirm("Are you sure you want to delete member?");
		if (r==true)
		{
			var index = x-1;
			$(".btn-removemember:eq("+index+")").attr('disabled','disabled');
			$.ajax({
				type: "POST",
				url: base_url + "users/delete/",
				data: {intID: x},
				statusCode: {
					500: function() { alert('An error occured. Please try again later.'); $(".btn-removemember:eq("+index+")").removeAttr('disabled'); },
					200: function(response){
							var res = $.parseJSON(response);
							if(res.success==1)
							{
								parent.document.location=parent.document.location;
							}
							else
							{
								alert('An error occured. Please try again later.');
								$(".btn-removemember:eq("+index+")").removeAttr('disabled');
							}
						},
				}
			});
		}
	}
	
	function edit_member(x){
		var src = base_url + "users/edit_member/" +x;
		$("#editmember-modal > iframe").attr('src',src);
		$("#editmember-modal").modal('show');
	}
	
	function edit_about(){
		var text = $('#btn-editabout').text();
		if(text == 'EDIT ABOUT'){
			$('#edit-band-profile').removeAttr('disabled');
			$('#btn-editabout').text('SAVE');
		}else{
			var x = $('#edit-band-profile').val();
			$.ajax({
				type: "POST",
				url: base_url + "users/edit/",
				data: {strProfile: x},
				statusCode: {
					500: function() { alert('An error occured. Please try again later.');},
					200: function(response){
							var res = $.parseJSON(response);
							if(res.success==1)
							{
								parent.document.location=parent.document.location;
							}
							else
							{
								$('#edit-about-message').html(res.message);
								//alert('An error occured. Please try again later.');
								//$(".btn-removemember:eq("+index+")").removeAttr('disabled');
							}
						},
				}
			});
		}
	}
	
	function edit_location(){
		var text = $('#btn-editlocation').text();
		if(text == 'EDIT LOCATION')
		{
			$('#btn-editlocation').text('SAVE');
			$('#strLocation').removeAttr('disabled');
		}
		else
		{
			var x = $('#strLocation').val();
			$.ajax({
				type: "POST",
				url: base_url + "users/edit_location/",
				data: {region: x},
				statusCode: {
					500: function() { alert('An error occured. Please try again later.');},
					200: function(response){
							var res = $.parseJSON(response);
							if(res.success==1)
							{
								parent.document.location=parent.document.location;
							}
							else
							{
								$('#message-edit-location').html(res.message);
								//alert('An error occured. Please try again later.');
								//$(".btn-removemember:eq("+index+")").removeAttr('disabled');
							}
						},
				}
			});
		}
	}
	
</script>